/** 
 * @Description: 标绘图片
 * @Author: 程前
 * @Date: 2024-12-09 15:38:51
 * @LastEditors: 程前
 * @LastEditTime: 2024-12-23 11:55:32
 */
import { Viewer, Entity, ScreenSpaceEventHandler } from "cesium";
import BaseLoader from "../base"
import { ICesiumLoader } from "@/types/loader";
import ImagePlotting from "@/cesium/plotting";
import { useCesiumGlobalStore } from "@/store/modules/cesiun-global"
import { useCesiumEditStore } from "@/store/modules/cesium-edit";


export default class Plotting extends BaseLoader implements ICesiumLoader {
    viewer: Viewer;
    entity: Entity;
    loader: ImagePlotting;
    imgSrc: string = '';
    handler: ScreenSpaceEventHandler | null = null
    constructor(viewer: Viewer) {
        super(viewer);
        this.viewer = viewer;
        this.handler = new ScreenSpaceEventHandler(this.viewer.scene.canvas);
        this.init(viewer, this.handler);
    }

    init(viewer: Viewer, handler: ScreenSpaceEventHandler): void {
        this.loader = new ImagePlotting(viewer, handler);
        this.loader.initEvents()
    }


    getData(): Record<string, any> {
        throw new Error('Method not implemented.');
    }

    getEntity(): Entity | void {
        throw new Error('Method not implemented.');
    }

    remove(): boolean {
        throw new Error('Method not implemented.');
    }

    destroy(): void {
        this.loader.destroy()
        super.removeEscEvent()
        useCesiumGlobalStore().loader = null
        //重置默认配置
        const cesiumEditStore = useCesiumEditStore()
        const defaultConfig = {
            name: '',
            labelColor: "#fff",
            rotation: 0,
            isClampToGround: false
        }
        cesiumEditStore.plotting.imageConfig = defaultConfig
        cesiumEditStore.plotting.vectorConfig = {
            ...defaultConfig,
            color: "#000",
        }
    }
}